package com.xu.cloud.common.validation;

import com.xu.cloud.common.validation.validator.HasOptionalValueValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 校验参数是否在可选值范围
 *
 * @author xuguan
 * @since 2023/11/10
 */
@Documented
@Target({FIELD, METHOD, PARAMETER, TYPE_PARAMETER})
@Retention(RUNTIME)
@Constraint(validatedBy = {HasOptionalValueValidator.class})
public @interface HasOptionalValue {

    String message() default "参数不在可选值范围, 请重新输入";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 可选值数组
     */
    String[] optionalValues() default {};
}
